<link href="__CDN__/assets/css/app_new.css" rel="stylesheet">
<style>
    .sub-merchant-wrap {
        /* .88 */
        padding: 1.26rem .3rem 0 .3rem;
    }

    .sub-merchant-wrap .level-info-wrap {
        margin-bottom: .2rem;
    }

    .sub-merchant-wrap .level-info-wrap .id {
        font-size: 0.34rem;
        font-weight: 400;
        color: #000;
        margin-bottom: 0.2rem;
        line-height: 1.5;
    }

    .sub-merchant-wrap .level-info-wrap .nickname {
        font-size: 0.26rem;
        color: #777;
        line-height: 1.5;
    }

    .sub-merchant-wrap .level-info-wrap .time {
        font-size: 0.26rem;
        color: #777;
        line-height: 1.5;
    }

    .sub-merchant-wrap .people-count-inner {
        color: #ff7300;
        border: 1px solid #ff7300;
        border-radius: 0.08rem;
        height: .72rem;
        line-height: .72rem;
        text-align: center;
        font-size: 0.3rem;
        width: 100%;
        margin-bottom: .2rem;
    }

    .level2-group {
        position: fixed;
        width: 100%;
        height: 99%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .CollectList {
        padding-left: 0;
    }
</style>
<div class="all-container">
    <div class="login-register-header">
        <div class="CommonHeader">
            <div class="CommonBackBtn"><a href="javascript:history.go(-1)"><img src="/map/images/return_black.png"
                        alt="返回"></a></div>
            <div class="CommonTitle">二级会员</div>
        </div>
        <div class="sub-merchant-wrap">
            <div class="level-info-wrap level-one">
                <p class="id"></p>
                <p class="nickname"></p>
            </div>
            <div class="people-count-inner">一级会员(<span class="num"></span>)人</div>
            <div class="level2-group">
                <div class="CollectList"></div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="__CDN__/assets/js/PullToRefresh.min.js"></script>
<script>
    let page = 1;
    let flag = false;
    var refreshBox = new PullToRefresh({
        container: ".level2-group",
        // pull: {
        //     callback: function () {
        //         setTimeout(function () {
        //             myteam_users();
        //             refreshBox.endPullRefresh(true);
        //         }, 1000);
        //     }
        // },
        up: {
            callback: function () {
                setTimeout(function () {
                    getPageDate();
                    refreshBox.endUpLoading(flag);
                }, 1000);
            }
        }
    });

    function getPageDate() {
        $.post("{:url('user/selectsers')}", {
            live: 2,
            parent_user_id: "{$parent_user_id}",
            // 页码
            offset: page,
        }, function (res) {
            console.log(res.data)
            if(res.data.count == 0){
                $('.people-count-inner .num').html('0')
            }
            if (res.code == 1) {
                $('.level-one .id').html('会员ID:' + res.data.my.id)
                $('.level-one .nickname').html('会员昵称:' + res.data.my.username)
                $('.people-count-inner .num').html(res.data.count)

                $.each(res.data.data, function (index, value) {
                    let template = `<div class="level-info-wrap">
                    <p class="id">会员ID: ${value.id}</p>
                    <p class="nickname">会员昵称: ${value.username}</p>
                    <p class="time">会员申请时间: ${value.createtime}</p>
                </div>`
                    $(".CollectList").append(template);
                })
                page++
            } else if(res.code == 0){
                $('.level-one .id').html('会员ID:' + res.data.my.id)
                $('.level-one .nickname').html('会员昵称:' + res.data.my.username)
                $('.people-count-inner .num').html(res.data.count)
            }else {
                $(".loadingBox").html("没有更多数据了");
                flag = false;
                refreshBox.endPullRefresh(false);
            }

        });
    }
</script>